package Test_0807;

import java.util.Objects;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 * Dare: 2024-08-07
 * Time: 19:19
 */
public class Dog extends Animal implements IRun{
    public Dog(String name, int age) {
        super(name, age);
    }
    @Override
    public void eat() {
        System.out.println(this.name+"吃狗粮");
    }
    @Override
    public void run(){
        System.out.println(this.name+"会跑");
    }

    @Override
    public int hashCode() {
        return Objects.hash();
    }

    @Override
    public boolean equals(Object obj) {
        if(obj == null){
            return false;
        }
        if(obj == this){
            return true;
        }
        //如果不是同一类型
        if(!(obj instanceof Dog)){
            return false;
        }
        Dog dog=(Dog)obj;
        return dog.name.equals(this.name)
        && dog.age==this.age;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name=" + name +
                ", age=" + age +
                '}';
    }
}
